//
//  STNewOrderInfoItemView.swift
//  SeaTransportManage
//
//  Created by guopengwen on 2021/11/26.
//

import UIKit

class STNewOrderInfoItemView: UIView {
    
    var type: Int
    
    override init(frame: CGRect) {
        self.type = 0
        super.init(frame: frame)
    }

    convenience init(type: Int ) {
        self.init(frame: CGRect.zero)
        self.type = type
        
        let circleView: UIView = UIView.init()
        circleView.layer.cornerRadius = 10
        addSubview(circleView)
        circleView.snp.makeConstraints { (make) in
            make.top.equalTo(0)
            make.left.equalTo(16)
            make.width.equalTo(20)
            make.height.equalTo(20)
        }
        
        circleView.addSubview(noteLabel)
        noteLabel.snp.makeConstraints { (make) in
            make.top.equalTo(0)
            make.left.equalTo(0)
            make.width.equalTo(20)
            make.height.equalTo(20)
        }
        
        addSubview(descLabel)
        descLabel.snp.makeConstraints { (make) in
            make.centerY.equalTo(circleView)
            make.left.equalTo(circleView.snp.right).offset(6)
            make.right.equalTo(-16)
            make.height.equalTo(20)
        }
        
        if(type == 0) {
            circleView.backgroundColor = UIColor.init(hexString:"#01DD9C", alpha: 1)
            noteLabel.text = "员"
        } else if(type == 1) {
            circleView.backgroundColor = UIColor.init(hexString:"#3686FF", alpha: 1)
            noteLabel.text = "单"
        } else {
            circleView.backgroundColor = UIColor.init(hexString:"#FA951E", alpha: 1)
            noteLabel.text = "时"
        }
    }
    
    public func updateValue(_ str: String) {
        descLabel.text = str
    }
    
    lazy var noteLabel: UILabel = {
        let lb = UILabel.init()
        lb.textAlignment = .center
        lb.textColor = UIColor.white
        lb.font = UIFont.systemFont(ofSize: 14)
        return lb
    }()
    
    lazy var descLabel: UILabel = {
        let lb = UILabel.init()
        lb.font = UIFont.systemFont(ofSize: 16)
        return lb
    }()
    
    required init?(coder aDecoder: NSCoder) {
        self.type = 0
        super.init(coder: aDecoder)
        fatalError("init(coder:) has not been implemented")
    }
}
